package net.news.dao;

import java.util.List;

import net.news.entity.NewsPeople;

import org.springframework.stereotype.Repository;

import com.liesp.base.BaseDAO;
import com.liesp.util.PropertyFilter;

/**
 * 项目名称：cmunews3084<br>
 * 类名称：NewsPeopleDao <br>
 * 类描述： TODO(请输入类的描述) <br>
 * 创建人：charles 创建时间：2011-5-10 上午11:42:07 <br>
 * 修改人： 修改时间： <br>
 * 修改备注：
 * 
 * @version V1.0
 */
@Repository
public class NewsPeopleDao extends BaseDAO<NewsPeople, Integer> {

	/**
	 * 根据用户名和密码查询用户信息
	 * 
	 * @param newsPeople
	 *            用户实体类
	 * @return
	 */
	public List<NewsPeople> findNewsPeople(NewsPeople newsPeople) {
		String hql = "from NewsPeople as np where np.name=? and np.psw=?";
		return this.findByHql(hql, new Object[] { newsPeople.getName(),
				newsPeople.getPsw() });
	}

	/**
	 * 根据id查询发布人
	 * 
	 * @param newsPeople
	 *            发布人
	 * @return
	 */
	public List<NewsPeople> findNewsPeopleById(NewsPeople newsPeople) {
		String hql="from NewsPeople where id=?";
		return findByHql(hql, new Object[]{newsPeople.getId()});
	}

	/**
	 * 保存管理员方法
	 * 
	 * @param newsPeople
	 */
	public void savaNewsPeople(NewsPeople newsPeople) {
		this.save(newsPeople);
	}

	/**
	 * 根据用户名查询用户
	 * 
	 * @param newsPeople
	 *            管理员实体，内含用户名
	 * @return
	 */
	public List<NewsPeople> findNewsPeoplesBoolean(NewsPeople newsPeople) {
		String hql = "from NewsPeople as  np where np.name=?";
		return this.findByHql(hql, new Object[] { newsPeople.getName() });
	}

	/**查询所有管理员
	 * @return
	 */
	public List<NewsPeople> findNps() {
		String hql="from NewsPeople order by id desc";
		return this.findByHql(hql);
	}

	/**根据条件模糊查询方法
	 * @param newsPeople 管理员实体
	 * @return
	 */
	public List<NewsPeople> findNPList(List<PropertyFilter> filters) {
		return this.find(filters);
	}
	
	/**删除管理员方法
	 * @param newsPeople
	 */
	public void deleteNewsPeople(NewsPeople newsPeople){
		this.delete(newsPeople);
	}
}
